package com.budong.utils;

import com.alibaba.fastjson.JSON;

import java.util.Arrays;
import java.util.List;

/**
 * Created by jianweilin on 2016/12/25.
 */
public class TimeUtils {
    public static Integer timePeriod(String startTime,String endTime){
        List<String> start = Arrays.asList(startTime.split(":"));
        System.out.println("start => " + JSON.toJSONString(start));

        List<String> end = Arrays.asList(endTime.split(":"));
        System.out.println("end => " + JSON.toJSONString(end));

        Integer startSeconds = Integer.valueOf(start.get(0)) * 3600 + Integer.valueOf(start.get(1)) * 60 + Integer.valueOf(start.get(2));
        System.out.println("startSeconds => " + startSeconds);
        Integer endSeconds = Integer.valueOf(end.get(0)) * 3600 + Integer.valueOf(end.get(1)) * 60 + Integer.valueOf(end.get(2));
        System.out.println("endSeconds => " + endSeconds);
        return (endSeconds - startSeconds) == 0 ? 1 :(endSeconds - startSeconds) ;
    }

    public static void main(String[] args) {
        System.out.println(timePeriod("00:01:00","00:01:10"));
    }
}
